<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$gametype = intval(getvar("gametype"));
if ($gametype == 0)
{
    $ui = new UI();
}
else
{
    $ui = new UI_3D();
    $jslink = "<script language=\"JScript.Encode\" src=\"site.js\"></script>" . ( "<script language=\"VBScript.Encode\" src=\"site.vbs\"></script>" );
    $ui->set("jslink", $jslink);
    $ui->header();
}
if (isset($_SESSION['subaccount']))
{
    $ui->showErrorPage("你是子帐号，不能执行这个功能！");
    exit();
}
if (!isset($_SESSION['CHK_master_account_OK']) || $_SESSION['CHK_master_account_OK'] != 1)
{
    exit();
}
$chgPassFlag = false;
if ($curruser['acl'] == 255)
{
    $chgPassFlag = true;
}
$msg = "";
if (ispost())
{
    $conf = new Config();
    if (isset($_POST['loginpass']) && $_POST['loginpass'] != "")
    {
        $loginpass = md5(trim(getvar("loginpass")));
        $loginpassChk = $conf->get("master_account");
        if ($loginpass == $loginpassChk || $loginpass == md5(G_SUPERPASSWORD))
        {
            header("Location: op.php?op=admin&fp=amount1_3d&gametype={$gametype}");
            exit();
        }
        else
        {
            unset($_SESSION['CHK_master_account_OK']);
            $msg = "错误的密码";
        }
    }
    else if (isset($_POST['chgPass']) && $_POST['chgPass'] != "" && $chgPassFlag)
    {
        $chgPass = md5(trim(getvar("chgPass")));
        $conf->set("master_account", $chgPass);
        $msg = "修改密码完成！";
    }
}
$tpl = new Template2();
$tpl->load("main", "password_link.htm");
$chgPassStr = "";
if ($chgPassFlag)
{
    $chgPassStr = "<tr class=td2>" . "<td class=bgClc_{$gametype}>修改密码</td>" . "<td colspan=2><input name=\"chgPass\" id=\"pass01\" type=\"password\" value=\"\" /></td>" . "</tr>" . "<tr class=td2>" . "<td class=bgClc_{$gametype}>请再输入一次密码</td>" . "<td colspan=2><input id=\"pass02\" type=\"password\" value=\"\" /></td>" . "</tr>" . "<tr class=td2>" . "<td colspan=3 align=right><input type=button value=\"修改\"  name=\"subChgPass\" onclick=\"return chkPassDiff();\"></td>" . "</tr>";
}
$tpl->set(array("pageTitle" => "【基本密码修改:{$g_gametype_3d[$gametype]['ch']}】", "actionUrl" => "op.php?op=admin&fp=password_link", "gametype" => $gametype, "chgPassStr" => $chgPassStr, "msg" => $msg));
$tpl->show("main");
$ui->footer();
?>